{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>机构风采</h5>
            <div class="ibox-tools">
                <a class="collapse-link">
                    <i class="fa fa-chevron-up"></i>
                </a>
            </div>
        </div>
        <div class="ibox-content">
            <!--搜索框开始-->           
            <div class="row">
                <div class="col-sm-12">   
                    <div  class="col-sm-3">
                        <div class="input-group" >
                            <a href="{:url('Mechanism/index')}">
                                <button class="btn btn-outline btn-danger" >
                                    <i class="fa fa-mail-reply"></i> 返回机构列表
                                </button>
                            </a>
                            <!--{if($info.mechanism_type==1)}-->
                            <!--<a href="{:url('Mechanism/mienAdd')}">-->
                                <!--<button class="btn btn-outline btn-primary" type="button">-->
                                    <!--<i class="fa fa-plus"></i> 添加风采-->
                                <!--</button>-->
                            <!--</a>-->
                            <!--{/if}-->
                            <!--<button  class="btn btn-outline btn-danger" href="javascript:;" data-toggle="dropdown">-->
                                <!--<i class="fa fa-wrench"></i> 批量操作 <span class="caret"></span>-->
                            <!--</button>-->
                            <!--<ul class="dropdown-menu animated fadeInDown" role="menu">-->
                                <!--<li><a href="javascript:;" class="layuiBtn" id="empty" data-type="reload"><i class="fa fa-retweet"></i> 重置搜索框 </a></li>-->
                                <!--<li><a href="javascript:;" class="layuiBtn" data-type="getCheckData"><i class="fa fa-trash-o"></i> 批量删除 </a></li>-->
                                <!--<li><a  href="javascript:;" class="layuiBtn" data-type="usingAll" id="onAll"><i class="fa fa-check-circle"></i> 批量启用</a></li>-->
                                <!--<li><a  href="javascript:;" class="layuiBtn" data-type="forbiddenAll" id="offAll"><i class="fa fa-ban"></i> 批量禁用</a></li>-->
                                <!--<li><a  href="javascript:;" class="layuiBtn" data-type="excelAll" id="excel"><i class="fa fa-print"></i> 导出Excel</a></li>-->
                            <!--</ul>-->
                        </div>
                    </div>
                </div>
            </div>
            <!--搜索框结束-->
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="demo"></table>
                </div>
            </div>
            <!-- End Example Pagination -->
        </div>
    </div>
</div>
<!-- End Panel Other -->
</div>
{include file="public/footer" /}
<script>
        layui.use('table', function () {
            var table = layui.table
            , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("Mechanism/mechanismmien")}'
            , where: {id:{:session('mechanism_id')}}
            , page: true
            , even: false //开启隔行背景
            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            // ,width:100
            , cellMinWidth: 80
            , limits: [5, 10, 15, 20, 25, 30]
            , limit: "{:config('pages')}"
            , text: {
                none: '暂无数据' //默认：无数据。注：该属性为 layui 2.2.5 开始新增
            }
            , loading: true
            , id: 'testReload'
            , cols: [[
//                {type: 'checkbox', fixed: 'left',},
                {type:'numbers', width: 60, title: '序号'}
                , {field: 'mien_url', width: 100, title: '风采图片', sort: false, align: 'center', templet: '#imgTpl'}
                , {field: 'mien_description', title: '介绍', sort: false, align: 'center'}
                , {fixed: 'right', width:170, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
                $.each(res.data,function(index,item){
                    $('#view_'+item['id']).viewer({
                        url: 'data-original',
                    });
                });
            }
        });
        //监听状态开关操作
        form.on('switch(OnOff)', function (obj) {
            // layer.tips(this.value + ' ' + this.name + '：'+ obj.elem.checked, obj.othis);
            if(obj.elem.checked == true){
                var num = 1;
            }else{
                var num = 2;
            }
            //用户状态
            wk.status(this.value,num, '{:url("uUserStatus")}');
        });
        //搜索表格重载
        var $ = layui.$, active = {
            reload: function () {
                //执行重载
                table.reload('testReload', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    , where:$('#layuiForm').parseForm()
                });
            }
            ,getCheckData: function(){
                //批量删除
                wk.batchDel(getIds(),"{:url('batchDelUser')}");
            }
            ,forbiddenAll: function(){
                //批量禁用
                wk.batchForbidden(getIds(),2,"{:url('forbiddenAdmin')}");
            }
            ,usingAll: function(){
                //批量启用
                wk.usingAll(getIds(),1,"{:url('usingAdmin')}");
            }
            ,excelAll: function(){
                //导出Excel
                wk.excelAll(getIds(),$('#layuiForm').serialize(),"{:url('excelAdmin')}");
            }
        };
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['id'])
            });
            return ids;
        }
    });
</script>
<!--图片模板-->
<script type="text/html" id="imgTpl">
    <ul onclick="view(this)" id="view_{{d.mien_id}}">
        <li><img data-original="{{d.mien_url}}" src="{{d.mien_url}}" class="img-circle table-img" onerror="this.src='/static/admin/images/head_default.gif'"  /></li>
    </ul>
</script>
<!--角色模板-->
<script type="text/html" id="statusTpl">
    {{# if(d.mechanism_status == 3){ }}
        审核失败
    {{# } }}
    {{# if(d.mechanism_status == 1){ }}
        审核中
    {{# } }}
    {{# if(d.mechanism_status == 2){ }}
        审核通过
    {{# } }}
</script>
<!--状态模板-->
<script type="text/html" id="staBar">
    <input type="hidden" id="zh{{d.user_id}}" value="{{d.user_status}}">
    <input type="checkbox"  id="zt{{d.user_id}}" value="{{d.user_id}}"  lay-skin="switch"  lay-text="ON|OFF" lay-filter="OnOff"{{ d.user_status == 1 ? 'checked' : '' }}  >
</script>
<!--操作模板-->
<script type="text/html" id="opeBar">
    <!--{{# if(d.mechanism_type == 1){ }}-->
    <!--<a href="javascript:location.href = '{:url('mienEdit')}?id={{d.mien_id}}';" class="btn btn-success btn-outline btn-xs" title="编辑"><i class="fa fa-server">编辑</i></a>&nbsp;-->
    <!--{{# } }}-->
</script>
</body>
</html>